app.controller('wzgyhxq',['$scope','$http','wzgyhData','$location','mainService',function ($scope,$http,wzgyhData,$location,mainService) {

    $scope.x = wzgyhData.getData();
    $scope.picPath =mainUrl+$scope.x.yhPicPath;
    //console.log(wzgyhData.getData())
    $scope.submit = function () {
        if(getInputs()==false){
            return;
        }
        mui.showLoading('加载中...','div');
        var token = localStorage.getItem('token');
        $http({
            method: "POST",
            url: mainUrl + '/tr/tr-reform-plan!updateActual4App.action',
            params: {
                'Authorization': token ,
                'qm.jsonStr':{
                    "reformDt":localStorage.getItem('dateInput') , //表单实际整改日期
                    "reformActual": mainService.getFzr().sid, //实际整改人sid
                    "actualId": mainService.getFzr().identityId, //实际整改人身份证
                    "actualName": $scope.fzr , //实际整改人中文
                    "consume":$scope.zgzj , //表单费用
                    "userName": $scope.yhxqFzr,//表单验收人中文
                    "id":mainService.getyhxqFzr().identityId ,//表单验收人身份证 (此处需要验证不等于当前登录人和不等与实际整改人actualId)
                    "acceptanceBy":mainService.getyhxqFzr().sid, //表单验收人sid
                    "troMethod": $scope.zgjg, //表单整改结果
                    "trpsid":wzgyhData.getData().zgjhSid ,//对应zgjhSid	整改计划sid
                    "version": 1, //默认1
                    "acceptanceOrp":mainService.getyhxqFzr().orpSid,
                    "sid": wzgyhData.getData().zgjhSid  //对应zgjhSid	整改计划sid
                    //"controlMeasures":wzgyhData.getData().controlMeasures //整改措施}
                        }
            }
        }).then(
            function (data, status, headers, config) {
                console.log(data);
                //$scope.data = data.data.items;

                mui.hideLoading();
                mui.toast('提交成功');
                // document.getElementsByClassName('mui-switch-blue').addEventListener
            }, function (data, status, headers, config) {
                console.log(data)
                mui.toast(data)
                console.log(status)
            })


        mainService.reset();
        $location.path('/weizenggaiyinhuan')
    }
    $scope.fzrtz = function ($event) {
        mainService.setFzrtz($event);
        $location.path('/renyuanxuanze')
    }
    $scope.fzr = mainService.getFzr().staffName;
    $scope.yhxqFzr = mainService.getyhxqFzr().staffName;
    $scope.yjyabj = function ($event) {
        mainService.setYjyabj($event);
        $location.path('/daibanyingjiyuan')
    }
    $scope.yjya = mainService.getYjya().planName;
    $scope.onChange = function () {

        mainService.setArr({
            zgzj:$scope.zgzj,
            zgjg:$scope.zgjg
        });
        console.log(mainService.getArr())
    }
    if(mainService.getArr()[0]) {
        if (mainService.getArr()[0].zgzj) {
            $scope.zgzj = mainService.getArr()[0].zgzj;
        }
        if (mainService.getArr()[0].zgjg) {
            $scope.zgjg = mainService.getArr()[0].zgjg;
        }

        mainService.clearArr();
    }
    $scope.showPic = function () {
        mui.showPic($scope.picPath,'div');
        // setTimeout(function () {
        //     mui.hidePic();
        // },1000)

    };
}]);